/**
 * 
 */
package controller;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.List;

import model.*;
import model.turtle.Turtle;
import view.Observer;
import view.SLogoView;

/**
 * The execute() function is provided to the view.
 */
public class Controller implements ActionListener
{
	private Model model;
	private Observer observer;
	public static final Dimension SIZE = new Dimension(600, 600);

	public Controller() throws IOException
	{
		observer = (new SLogoView(this)).getObserver();
		model = new Model();
		observer.update(model.getTurtles());
	}

	public void execute(String command)
	{
		List<Turtle> tmpList = model.execute(command);
		observer.update(tmpList);
	}

	@Override
	public void actionPerformed(ActionEvent e)
	{
		String command = e.getActionCommand();
		execute(command);
	}
}